/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package carrello.impl.boundary.administrator;

import carrello.impl.boundary.AbstractUI;
import carrello.impl.controller.administrator.UpdateCompanyInfoCTRL;
import carrello.model.entities.Company;

/**
 *
 * @author Mehdi
 */
public class UpdateCompanyInfoUI extends AbstractUI {

    private String name;
    private String slogan;
    private String url;
    private String email;
    private String phone;
    private String address;

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the slogan
     */
    public String getSlogan() {
        return slogan;
    }

    /**
     * @param slogan the slogan to set
     */
    public void setSlogan(String slogan) {
        this.slogan = slogan;
    }

    /**
     * @return the url
     */
    public String getUrl() {
        return url;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the phone
     */
    public String getPhone() {
        return phone;
    }

    /**
     * @param phone the phone to set
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String execute() {
        if ( !getSessionIsLoggedIn())
            return LOGIN;
        if (name == null) {
            Company c = UpdateCompanyInfoCTRL.getCompanyInfo ();
            name = c.getName();
            slogan = c.getSlogan();
            url = c.getUrl();
            email = c.getEmail();
            phone = c.getPhone();
            address = c.getAddress();
            return INPUT;
        } else {
            UpdateCompanyInfoCTRL companyCTRL = new UpdateCompanyInfoCTRL();
            companyCTRL.updateSystemInfo(name, slogan, url, email, phone, address);
        }
        return SUCCESS;

    }
    
    
}
